package com.hjm.project.ShopExpress.ShopExpress.controller;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.ShopExpress.ShopExpress.domain.ShopExpress;
import com.hjm.project.ShopExpress.ShopExpress.service.IShopExpressService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 物流基础信息Controller
 * 
 * @author ShopExpress
 * @date 2020-12-01
 */
@Controller
@RequestMapping("/ShopExpress/ShopExpress")
public class ShopExpressController extends BaseController
{
    private String prefix = "ShopExpress/ShopExpress";

    @Autowired
    private IShopExpressService shopExpressService;

    @RequiresPermissions("ShopExpress:ShopExpress:view")
    @GetMapping()
    public String ShopExpress()
    {
        return prefix + "/ShopExpress";
    }

    /**
     * 查询物流基础信息列表
     */
    @RequiresPermissions("ShopExpress:ShopExpress:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ShopExpress shopExpress)
    {
        startPage();
        List<ShopExpress> list = shopExpressService.selectShopExpressList(shopExpress);
        return getDataTable(list);
    }

    /**
     * 导出物流基础信息列表
     */
    @RequiresPermissions("ShopExpress:ShopExpress:export")
    @Log(title = "物流基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ShopExpress shopExpress)
    {
        List<ShopExpress> list = shopExpressService.selectShopExpressList(shopExpress);
        ExcelUtil<ShopExpress> util = new ExcelUtil<ShopExpress>(ShopExpress.class);
        return util.exportExcel(list, "ShopExpress");
    }

    /**
     * 新增物流基础信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存物流基础信息
     */
    @RequiresPermissions("ShopExpress:ShopExpress:add")
    @Log(title = "物流基础信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ShopExpress shopExpress)
    {
        return toAjax(shopExpressService.insertShopExpress(shopExpress));
    }

    /**
     * 修改物流基础信息
     */
    @GetMapping("/edit/{expressCode}")
    public String edit(@PathVariable("expressCode") String expressCode, ModelMap mmap)
    {
        ShopExpress shopExpress = shopExpressService.selectShopExpressById(expressCode);
        mmap.put("shopExpress", shopExpress);
        return prefix + "/edit";
    }

    /**
     * 修改保存物流基础信息
     */
    @RequiresPermissions("ShopExpress:ShopExpress:edit")
    @Log(title = "物流基础信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ShopExpress shopExpress)
    {
        return toAjax(shopExpressService.updateShopExpress(shopExpress));
    }

    /**
     * 删除物流基础信息
     */
    @RequiresPermissions("ShopExpress:ShopExpress:remove")
    @Log(title = "物流基础信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(shopExpressService.deleteShopExpressByIds(ids));
    }


}
